<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="profile.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>profile.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'profile.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="profile.html">profile</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**
 *	A profile is a set of tools grouped by similar objectives. For example, a profile of tools for building forms 
 *	or for building content in HTML.
 *	<span class="attrib">@author</span> Roosevelt de Lima Sardinha
 *	<span class="attrib">@constructor</span>	
 */</span>
<span class="reserved">function</span> profile(){
	<span class="comment">/**
	 * The unique id of the profile.
	 * <span class="attrib">@type</span> {Int}
	 */</span>
	<span class="reserved">this</span>.id = null;
	
	<span class="comment">/**
	 * The name of the profile. A way of making easy its identification by someone.
	 * <span class="attrib">@type</span> {String}
	 */</span>
	<span class="reserved">this</span>.name = null;
	
	<span class="comment">/**
	 * The description of the profile. Explains what are this set of tools for.
	 * <span class="attrib">@type</span> {String}
	 */</span>
	<span class="reserved">this</span>.description = null;
	
	<span class="comment">/**
	 * An array of strings containing the ids of all tools in the profile. The ids are the same name of the folder where the tool files are.
	 * <span class="attrib">@types</span> {Array}
	 */</span>
	<span class="reserved">this</span>.types = [];
	
	<span class="comment">/**
	 * Sets a value to some property of the profile.
	 * <span class="attrib">@param</span> {String} property The property to be set.
	 * <span class="attrib">@param</span> {String} value The value to set in the property.
	 */</span>
	<span class="reserved">this</span>.setProperties = <span class="reserved">function</span>(property, value){
		switch(property){
			case <span class="literal">'name'</span>:
				<span class="reserved">this</span>.name = value;
				break;
			case <span class="literal">'description'</span>:
				<span class="reserved">this</span>.description = value;
				break;
			case <span class="literal">'types'</span>:
				<span class="reserved">this</span>.types = value;
				break;
			default:
				break;
		}
	}
	
	<span class="comment">/**
	 * Adds more tools to the profile.
	 * <span class="attrib">@param</span> {Array} types_array An array containing all the ids of tools that are going to be added.
	 */</span>
	<span class="reserved">this</span>.addTool = <span class="reserved">function</span>(types_array){
		var req  = new request();
		var params = [];
		var json = {};
		json.types = types_array;
		params[<span class="literal">'json'</span>] = JSON.stringify(json);
		req.sendSincRequest(<span class="literal">'POST'</span>, params, <span class="literal">"profiles/"</span> + <span class="reserved">this</span>.id + <span class="literal">"/types"</span> , <span class="reserved">function</span>(response){});
	}
	
	<span class="comment">/**
	 * Removes a tool.
	 * <span class="attrib">@param</span> {String} type The id of the tool you want to remove.
	 */</span>
	<span class="reserved">this</span>.removeTool = <span class="reserved">function</span>(type){
		var req  = new request();		
		var params = [];
		var eoTypeId;
		var allEoTypesStr = <span class="literal">""</span>;
		var allEoTypes;
		req.sendSincRequest(<span class="literal">'GET'</span>, params, <span class="literal">"eo_types"</span>, <span class="reserved">function</span>(response){
			allEoTypesStr = response;
		});
		allEoTypes = JSON.parse(allEoTypesStr);
		
		<span class="reserved">for</span> (var i = 0; i &lt; allEoTypes[<span class="literal">'eo_types'</span>].length; i++){
			<span class="reserved">if</span> (allEoTypes[<span class="literal">'eo_types'</span>][i][<span class="literal">'name'</span>] == type){
				eoTypeId = allEoTypes[<span class="literal">'eo_types'</span>][i][<span class="literal">'id'</span>];
				break;
			} 
		}
		
		params[<span class="literal">'_method'</span>] = <span class="literal">'DELETE'</span>;
		req.sendSincRequest(<span class="literal">'POST'</span>, params, <span class="literal">"profiles/"</span> + <span class="reserved">this</span>.id + <span class="literal">"/types/"</span> + eoTypeId, <span class="reserved">function</span>(response){});
	}
	
	<span class="comment">/**
	 * Saves a profile in the database, for being loaded in another time.
	 */</span>
	<span class="reserved">this</span>.save = <span class="reserved">function</span>(){
		var exists = null;
		var id;
		var profileJSON = {};
		profileJSON.name = <span class="reserved">this</span>.name;
		profileJSON.description = <span class="reserved">this</span>.description;
		profileJSON.types = <span class="reserved">this</span>.types;
		var strJSON = JSON.stringify(profileJSON)
		
		var params = [];
		params[<span class="literal">'json'</span>] = strJSON;
		
		var myRequest = new request();	
		<span class="reserved">if</span> (<span class="reserved">this</span>.id != null) {
			myRequest.sendSincRequest(<span class="literal">'GET'</span>, null, <span class="literal">"profiles/"</span> + <span class="reserved">this</span>.id + <span class="literal">"/exist"</span>, <span class="reserved">function</span>(response){
				exists = response;
			});
		}
		
		<span class="comment">// Check if profile already exists</span>
		<span class="reserved">if</span> ((exists != null) &amp;&amp; JSON.parse(exists)){
			params[<span class="literal">'_method'</span>] = <span class="literal">'PUT'</span>;
	        myRequest.sendSincRequest(<span class="literal">'POST'</span>, params, <span class="literal">"profiles/"</span> + <span class="reserved">this</span>.id, <span class="reserved">function</span>(response){
			});
		}<span class="reserved">else</span>{
	        myRequest.sendSincRequest(<span class="literal">'POST'</span>, params, <span class="literal">"profiles"</span>, <span class="reserved">function</span>(response){
				id = response;
			});
			<span class="reserved">this</span>.id = JSON.parse(id);		
		}	
	}
}


</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Mon Feb 21 18:12:28 2011</div>
</body>
</html>
